home *** CD-ROM | disk | FTP | other *** search
-
- #include <stdio.h>
- #include <exec/types.h>
- #include <libraries/locale.h>
- #include <exec/memory.h>
- #include <dos/dosextens.h>
- #include <intuition/screens.h>
- #include <intuition/intuition.h>
- #include <intuition/gadgetclass.h>
- #include <libraries/gadtools.h>
- #include <diskfont/diskfont.h>
- #include <utility/utility.h>
- #include <graphics/gfxbase.h>
- #include <devices/console.h>
- #include <workbench/workbench.h>
- #include <graphics/scale.h>
- #include <clib/locale_protos.h>
- #include <clib/exec_protos.h>
- #include <clib/wb_protos.h>
- #include <clib/intuition_protos.h>
- #include <clib/gadtools_protos.h>
- #include <clib/graphics_protos.h>
- #include <clib/utility_protos.h>
- #include <string.h>
- #include <clib/diskfont_protos.h>
-
- #include <dos/dos.h>
- #include <dos/dostags.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <ctype.h>
- #include <libraries/reqtools.h>
-
- #include <clib/alib_protos.h>
- #include <clib/dos_protos.h>
- #include <clib/reqtools_protos.h>
-
- #include "NodeGUI.h"
-
- extern struct ReqToolsBase *ReqToolsBase;
- extern ULONG InfoWinActive;
- extern ULONG *rttags;
-
- #include "/common/ANSI_Codes.h"
- #include "/common/types.h"
- #include "/common/errors.h"
- #include "/common/defines.h"
- #include "/common/structures.h"
- #include "/common/strings.h"
- #include "/common/files.h"
-
- #include "Node_Console_Protos.h"
- #include "Node_Serial_Protos.h"
- #include "Node_Main_Protos.h"
- #include "Node_Misc_Protos.h"
- #include "Node_Input_Protos.h"
- #include "/library/hbbscommon_protos.h"
- #include "/library/hbbscommon_pragmas.h"
- #include "nodelibrary/hbbsnode_protos.h"
- #include "nodelibrary/hbbsnode_pragmas.h"
-
- extern int N_NodeNum;
- extern struct BBSGlobalData *BBSGlobal;
- extern struct NodeData *N_ND;
- extern struct Library *HBBSCommonBase;
- extern struct Library *HBBSNodeBase;
-
- #include "/common/shared_protos.h"
-
- short fposition(char *substr,char *str,ULONG startpos)
- {
- // returns an character offset of a substring in a string
- // this version is CASE SENSITIVE
- // returns -1 if substring not found in the string
-
- char *whstr;
- return((short)((whstr=strstr(str+startpos,substr)) ? (short)((LONG)whstr-(LONG)str) : -1));
- }
-
- void strftcpy(char *dest,char *source,int from,int topos)
- {
- int loop=from,pos=0;
- if (from<=strlen(source)-1)
- {
- while (source[loop] && loop<=topos)
- {
- dest[pos]=source[loop];
- loop++;
- pos++;
- }
- }
- dest[pos]=0;
- }
-
- char *HBBS_AccessName(V_SMALLNUM Access)
- {
- struct Node *node;
- V_BIGNUM loop;
- char tmpstr[10];
- sprintf(tmpstr,"%d",Access);
-
- // check all access levels!
- for (loop=0;loop<BBSGlobal->AcsLevels;loop++)
- {
- // get the level number node.
- if(node=GetNode(BBSGlobal->AcsLevelList,loop))
- {
- // same as the level we want to find ?
- if (stricmp(tmpstr,node->ln_Name)==0)
- {
- // yup, so get the name
- if(node=GetNode(BBSGlobal->AcsLevelNames,loop))
- {
- // and return it!
- return(node->ln_Name);
- }
- }
- }
- }
- return(NULL);
- }
-
- void PausePrompt(char *promptstr,ULONG Timeout)
- {
- char prompt[BIG_STR];
-
- if ((promptstr && promptstr[0]==0) || (!promptstr))
- {
- MenuPrompt("Press [Return] to continue!",' ');
- }
- else
- {
- strcpy(prompt,promptstr);
- HBBS_ModifyString(prompt);
- PutText(prompt);
- }
-
- Get_Line(GL_IMMEDIATE,'\0',1,Timeout,NULL);
- PutText("\n\r");
- }
-
- V_BOOL ContinuePrompt(char *promptstr,V_BIGNUM Flags)
- {
- V_BOOL retval=FALSE;
- char defaultchar='N';
-
- if (promptstr)
- {
- PutText(promptstr);
- }
- else
- {
- PutText(ANSI_RESET "Continue ");
-
- }
- if (Flags & DCP_ADDYN)
- {
- if (Flags & DEFAULT_YES) defaultchar='Y';
- // add to end of string
- MenuPrompt("[Y]es, [N]o : ",defaultchar);
- }
-
- strcpy(N_ND->CharsAllowed,"YyNn");
-
- Get_Line(GL_USECHARS|GL_DISPLAY|GL_EDIT|GL_IMMEDIATE,'\0',1,0,NULL);
-
- if (N_ND->OnlineStatus==OS_ONLINE)
- {
- if (((N_ND->CurrentLine[0]=='\0') && (Flags & DEFAULT_YES)) || (toupper(N_ND->CurrentLine[0])=='Y'))
- {
- retval=TRUE;
- }
- else
- {
- retval=FALSE;
- }
- }
-
- return(retval);
- }
-
- void DisplayBuffer(UBYTE *Buffer,ULONG Length,BOOL CheckSequences)
- {
- char *errorstr="<ERROR>";
- ULONG bufferpos=0,linepos;
- UBYTE LineBuffer[BIG_STR],checkstr[BIG_STR],tmpstr[BIG_STR],formatstr[20],outstr[BIG_STR],doorname[BIG_STR],dooroptions[BIG_STR];
- BOOL GotLine,Done;
- short startpos,endpos;
-
- PutText(ANSI_RESET);
- do
- {
- GotLine=FALSE;
- for (linepos=0;(bufferpos<Length) && (linepos<BIG_STR-1) && (!GotLine);bufferpos++) // -1 for null terminator that needs to be added
- {
-
- // *C* check code sizes and times of the two methods..
- // ok, there are two ways to check the data, here's the first, it's a bit more structured
-
- switch (Buffer[bufferpos])
- {
- case '\n':
- LineBuffer[linepos++]='\n';
- LineBuffer[linepos++]='\r';
- if (Buffer[bufferpos+1]=='\r')
- {
- bufferpos++;
- }
- GotLine=TRUE;
- break;
-
- case '\0':
- break;
- default:
- LineBuffer[linepos++]=Buffer[bufferpos];
- break;
- }
-
- // and this is the second, less structured way of doing it..
- /*
- if (Buffer[bufferpos]=='\n')
- {
- LineBuffer[linepos++]='\n';
- LineBuffer[linepos++]='\r';
- if (Buffer[bufferpos+1]=='\r')
- {
- bufferpos++;
- }
- GotLine=TRUE;
- }
- else
- {
- if (Buffer[bufferpos]!='\0')
- {
- LineBuffer[linepos]=Buffer[bufferpos];
- linepos++;
- }
- }
- */
- }
- LineBuffer[linepos]=0;
-
- if (CheckSequences)
- {
- Done=FALSE;
- strcpy(tmpstr,LineBuffer);
- LineBuffer[0]=0;
-
- while (!Done)
- {
- Done=TRUE;
-
- // is there a sequence introducer in the buffer ?
-
- if ((startpos=position("@^",tmpstr))>=0)
- {
- // yup, but is it followed by a sequence terminator ?
- if ((endpos=fposition("@",tmpstr,startpos+2))>=0)
- {
- // yes it is. so make sure we check for more sequences when we've done this one
- Done=FALSE;
-
- // get the sequence from the buffer.. missing off the introducer
- // and the terminator, i.e. the bit between the @^ and the @
-
- strftcpy(checkstr,tmpstr,startpos+2,endpos-1);
-
- // copy the normal text to the output buffer.
-
- if (startpos) strncat(LineBuffer,tmpstr,startpos);
-
- // modify our temporary buffer..
-
- strfcpy(tmpstr,tmpstr,endpos+1);
-
-
-
- formatstr[0]=0;
- if ((startpos=position("^",checkstr))>=0)
- {
- if (startpos)
- {
- strftcpy(formatstr,checkstr,0,startpos-1);
- }
- strfcpy(checkstr,checkstr,startpos+1);
- }
-
- StripSpaces(checkstr);
- if ((startpos=position(" ",checkstr))>=0)
- {
- strNcpy(doorname,checkstr,startpos);
- strftcpy(dooroptions,checkstr,startpos,strlen(checkstr)-1);
- /*
- PutText(doorname);
- PutText("\n\r");
- PutText(dooroptions);
- PutText("\n\r");
- */
- }
- else
- {
- strcpy(doorname,checkstr);
- dooroptions[0]=0;
- }
- if (stricmp(formatstr,"SYSDOOR")==0) GoSystemDoor(doorname,dooroptions); else
- if (stricmp(formatstr,"USERDOOR")==0) GoUserDoor(doorname,dooroptions); else
- if (stricmp(formatstr,"SCREEN")==0) DisplayScreen(checkstr); else
- if (stricmp(formatstr,"SSCREEN")==0) DisplaySpecialScreen(checkstr); else
- if (stricmp(formatstr,"PAUSE")==0) PausePrompt(checkstr,0); else
- if (stricmp(formatstr,"TPAUSE")==0) PausePrompt(NULL,atol(checkstr)); else
- if (stricmp(formatstr,"CLS")==0) PutText(ANSI_CLS); else
- {
-
- // check checkstr against table and store result in same variable.
-
- if (stricmp("BBSName",checkstr)==0) strcpy(checkstr,BBSGlobal->BBSName); else
- if (stricmp("BBSLocation",checkstr)==0) strcpy(checkstr,BBSGlobal->BBSLocation); else
- if (stricmp("BBSCountry",checkstr)==0) strcpy(checkstr,BBSGlobal->BBSCountry); else
- if (stricmp("Sysop",checkstr)==0) strcpy(checkstr,BBSGlobal->SysopAccount); else
-
- if (stricmp("BBSSerial",checkstr)==0) sprintf(checkstr,"%d",BBSGlobal->BBSSerial); else
- if (stricmp("BBSNodes",checkstr)==0) sprintf(checkstr,"%d",BBSGlobal->BBSNodes); else
- if (stricmp("TotalUsers",checkstr)==0) sprintf(checkstr,"%d",BBSGlobal->TotalUsers); else
- if (stricmp("Conferences",checkstr)==0) sprintf(checkstr,"%d",BBSGlobal->Conferences); else
-
- if (N_ND->User.Valid)
- {
- if (stricmp("Handle",checkstr)==0) strcpy(checkstr,N_ND->User.CallData.Handle); else
- if (stricmp("RealName",checkstr)==0) strcpy(checkstr,N_ND->User.CallData.RealName); else
- if (stricmp("Group",checkstr)==0) strcpy(checkstr,N_ND->User.CallData.Group); else
- if (stricmp("GeoLocation",checkstr)==0) strcpy(checkstr,N_ND->User.CallData.GeoLocation); else
- if (stricmp("Country",checkstr)==0) strcpy(checkstr,N_ND->User.CallData.Country); else
- if (stricmp("PhoneNumber",checkstr)==0) strcpy(checkstr,N_ND->User.CallData.PhoneNumber); else
- if (stricmp("Password",checkstr)==0) strcpy(checkstr,N_ND->User.CallData.Password); else
- if (stricmp("ComputerType",checkstr)==0) strcpy(checkstr,N_ND->User.CallData.ComputerType); else
-
- if (stricmp("AccessName",checkstr)==0) strcpy(checkstr,HBBS_AccessName(N_ND->User.CallData.Access)); else
- if (stricmp("LastConf",checkstr)==0) strcpy(checkstr,HBBS_ListName(BBSGlobal->ConfList,N_ND->User.CallData.LastConf-1)); else
- if (stricmp("PreferedConf",checkstr)==0) strcpy(checkstr,HBBS_ListName(BBSGlobal->ConfList,N_ND->User.CallData.PreferedConf)); else
-
- if (stricmp("Access",checkstr)==0) sprintf(checkstr,"%d",N_ND->User.CallData.Access); else
- if (stricmp("UserID",checkstr)==0) sprintf(checkstr,"%d",N_ND->User.CallData.UserID); else
- if (stricmp("UploadBytes",checkstr)==0) sprintf(checkstr,"%d",N_ND->User.CallData.UploadBytes); else
- if (stricmp("DownloadBytes",checkstr)==0) sprintf(checkstr,"%d",N_ND->User.CallData.DownloadBytes); else
- if (stricmp("UploadFiles",checkstr)==0) sprintf(checkstr,"%d",N_ND->User.CallData.UploadFiles); else
- if (stricmp("DownloadFiles",checkstr)==0) sprintf(checkstr,"%d",N_ND->User.CallData.DownloadFiles); else
- if (stricmp("A_UploadBytes",checkstr)==0) sprintf(checkstr,"%d",N_ND->User.CallData.ActualUploadBytes); else
- if (stricmp("A_DownloadBytes",checkstr)==0) sprintf(checkstr,"%d",N_ND->User.CallData.ActualDownloadBytes); else
- if (stricmp("A_UploadFiles",checkstr)==0) sprintf(checkstr,"%d",N_ND->User.CallData.ActualUploadFiles); else
- if (stricmp("A_DownloadFiles",checkstr)==0) sprintf(checkstr,"%d",N_ND->User.CallData.ActualDownloadFiles); else
-
- if (stricmp("BestCPSUp",checkstr)==0) sprintf(checkstr,"%d",N_ND->User.CallData.BestCPSUp); else
- if (stricmp("BestCPSDown",checkstr)==0) sprintf(checkstr,"%d",N_ND->User.CallData.BestCPSDown); else
- if (stricmp("CallsMade",checkstr)==0) sprintf(checkstr,"%d",N_ND->User.CallData.CallsMade); else
- if (stricmp("PagesMade",checkstr)==0) sprintf(checkstr,"%d",N_ND->User.CallData.PagesMade); else
- if (stricmp("MessagesWritten",checkstr)==0) sprintf(checkstr,"%d",N_ND->User.CallData.MessagesWritten); else
- if (stricmp("BRatio",checkstr)==0) sprintf(checkstr,"%d",N_ND->User.CallData.BytesRatio); else
- if (stricmp("FRatio",checkstr)==0) sprintf(checkstr,"%d",N_ND->User.CallData.FilesRatio); else
- if (stricmp("LastConfNum",checkstr)==0) sprintf(checkstr,"%d",N_ND->User.CallData.LastConf); else
- if (stricmp("PreferedConfNum",checkstr)==0) sprintf(checkstr,"%d",N_ND->User.CallData.PreferedConf); else
- if (stricmp("LinesPerScreen",checkstr)==0) sprintf(checkstr,"%d",N_ND->User.CallData.LinesPerScreen); else
- if (stricmp("BytesAllowed",checkstr)==0) sprintf(checkstr,"%d",N_ND->User.CallData.BytesAllowed); else
- if (stricmp("TimeAllowed",checkstr)==0) sprintf(checkstr,"%d",N_ND->User.CallData.TimeAllowed); else
- if (stricmp("ChatAllowed",checkstr)==0) sprintf(checkstr,"%d",N_ND->User.CallData.ChatAllowed); else
- if (stricmp("CallsAllowed",checkstr)==0) sprintf(checkstr,"%d",N_ND->User.CallData.CallsAllowed); else
- if (stricmp("BytesUsed",checkstr)==0) sprintf(checkstr,"%d",N_ND->User.CallData.BytesUsed); else
- if (stricmp("TimeUsed",checkstr)==0) sprintf(checkstr,"%d",N_ND->User.CallData.TimeUsed); else
- if (stricmp("ChatUsed",checkstr)==0) sprintf(checkstr,"%d",N_ND->User.CallData.ChatUsed); else
- if (stricmp("CallsUsed",checkstr)==0) sprintf(checkstr,"%d",N_ND->User.CallData.CallsUsed); else
- if (stricmp("UserType",checkstr)==0) sprintf(checkstr,"%c",N_ND->User.CallData.UserType); else
- if (stricmp("Status",checkstr)==0) sprintf(checkstr,"%c",N_ND->User.CallData.Status);
- else
- strcpy(checkstr,errorstr);
- }
- else
- strcpy(checkstr,errorstr);
- sprintf(outstr,"%%%ss",formatstr);
- sprintf(LineBuffer+strlen(LineBuffer),outstr,checkstr);
- }
- }
- }
- }
- strcat(LineBuffer,tmpstr); // and copy what's left..
- }
- PutText(LineBuffer);
- }
- while (bufferpos<Length);
- PutText(ANSI_RESET);
-
- }
-
- V_BOOL DisplayScreen(char *ScreenName)
- {
- BPTR FH,FL;
- struct FileInfoBlock FIB;
- UBYTE *buffer;
- ULONG bytes;
- BOOL retval=FALSE;
-
-
- // if we are online or the activedoor is "Awaiting Connect"
- // AND file exists then continue..
-
- if (((N_ND->OnlineStatus==OS_ONLINE) || ((N_ND->ActiveDoor) && (iposition("AWAITING CONNECT",N_ND->ActiveDoor->node.ln_Name)>=0))) &&
- (AssignOK(ScreenName)) && (FL=Lock(ScreenName,ACCESS_READ)))
- {
- if (Examine(FL,&FIB))
- {
- if (FIB.fib_Size)
- {
- if (buffer=AllocVec(FIB.fib_Size,MEMF_PUBLIC))
- {
- if (FH=OpenFromLock(FL))
- {
- retval=TRUE;
- if (bytes=Read(FH,buffer,FIB.fib_Size))
- {
-
- if (FIB.fib_Size>3) //is file too small to be a file with a sequence in it ?
- { // No!
- // check the first three bytes and see if they are the same as the
- // sequence introducer.
-
- if (strncmp(buffer,"@^@",3)==0)
- {
- // ok, this file may contain more sequences so we set the following flag.
- DisplayBuffer(buffer+3,bytes-3,TRUE); // +/- 3 to skip the @^@..
- }
- else DisplayBuffer(buffer,bytes,FALSE);
-
-
- }
- else
- { // Yes, so read and display all the file...
- DisplayBuffer(buffer,bytes,FALSE);
- }
- }
- Close(FH);
- FL=NULL;
-
- }
- FreeVec(buffer);
- }
- }
- }
- if (FL) UnLock(FL);
- }
- return(retval);
- }
-
- /*
- void MenuPrompt(char *promptstr,char promptdefault)
- {
- char tmpstr[1024];
- char matchstr[4];
- char replacestr[1024];
-
- strcpy(tmpstr,promptstr);
-
- if (promptdefault!=' ')
- {
- sprintf(matchstr,"[%c]",promptdefault);
- sprintf(replacestr,"["ANSI_BOLD"%c"ANSI_RESET"]",promptdefault);
-
- replace(tmpstr,tmpstr,matchstr,replacestr);
- }
-
- if (tmpstr[0]=='[')
- {
- strcpy(replacestr,ANSI_FG_BLUE "[" ANSI_FG_YELLOW);
- strcat(replacestr,&tmpstr[1]);
- strcpy(tmpstr,replacestr);
- }
-
- replace(tmpstr,tmpstr," ["," "ANSI_FG_BLUE "[" ANSI_FG_YELLOW);
- replace(tmpstr,tmpstr,"]",ANSI_FG_BLUE "]" ANSI_FG_WHITE);
-
- PutText(ANSI_RESET);
- PutText(tmpstr);
- }
-
- V_STRING MenuTextANSI; // default: "white"
- V_STRING MenuOpenBracket; // default: [ "blue + ["
- V_STRING MenuCloseBracket; // default: ] "blue + ]"
- V_STRING MenuHighlightANSI; // default: "yellow"
- V_STRING MenuDefaultOptANSI; // default: "bold + white"
- V_STRING MenuPromptANSI; // default: : " blue + : "
-
- */
-
- void MenuPrompt(char *promptstr,char promptdefault)
- {
- char tmpstr[1024];
- char matchstr[4];
- char replacestr[1024];
-
- strcpy(tmpstr,promptstr);
-
- if (promptdefault!=' ')
- {
- sprintf(matchstr,"[%c]",promptdefault);
- sprintf(replacestr,"%s%s%c%s",N_ND->BBSCols->MenuOpenBracket,N_ND->BBSCols->MenuDefaultOptANSI,promptdefault,N_ND->BBSCols->MenuCloseBracket);
-
- replace(tmpstr,tmpstr,matchstr,replacestr);
- }
-
- if (tmpstr[0]=='[')
- {
- strcpy(replacestr,N_ND->BBSCols->MenuOpenBracket);
- strcat(replacestr,N_ND->BBSCols->MenuHighlightANSI);
- strcat(replacestr,&tmpstr[1]);
- strcpy(tmpstr,replacestr);
- }
-
- replacestr[0]=' ';
- replacestr[1]=0;
- strcat(replacestr,N_ND->BBSCols->MenuOpenBracket);
- strcat(replacestr,N_ND->BBSCols->MenuHighlightANSI);
- replace(tmpstr,tmpstr," [",replacestr);
-
- strcpy(replacestr,N_ND->BBSCols->MenuCloseBracket);
- strcat(replacestr,N_ND->BBSCols->MenuTextANSI);
- replace(tmpstr,tmpstr,"]",replacestr);
-
- PutText(ANSI_RESET);
- PutText(tmpstr);
- // PutText(N_ND->BBSCols->MenuPromptANSI);
- }
-